package com.geetour.columbus.customer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.geetour.columbus.common.model.C.Account;
import com.geetour.columbus.common.service.IAccountService;

@Controller
public class AccountController {

    private IAccountService accountServiceImpl;

    @Autowired
    public void setAccountServiceImpl(IAccountService accountServiceImpl) {
        this.accountServiceImpl = accountServiceImpl;
    }

    @RequestMapping("/customer/accountInit.jsp")
    public String init() {
        return "/customer/account.html";
    }

    @RequestMapping("/customer/createAccount.jsp")
    public String createAccount(ModelMap modelMap, Account account) {
        int result = accountServiceImpl.createAccount(account);
        modelMap.put("result", result);
        return "/customer/account.html";
    }

    @RequestMapping("/customer/updateAccount.jsp")
    public String updateAccount(ModelMap modelMap, Account account) {
        int result = accountServiceImpl.updateAccount(account);
        modelMap.put("account", account);
        modelMap.put("result", result);
        return "/customer/account.html";
    }

    @RequestMapping("/customer/accountDetail.jsp")
    public String accountDetail(ModelMap modelMap, Long accountId) {
        Account account = accountServiceImpl.getAccountById(accountId);
        modelMap.put("account", account);
        return "/customer/account.html";
    }
}
